package com.example.backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.backend.entity.XiangQing;
import com.example.backend.mapper.XiangQingMapper;
import com.example.backend.service.IXiangQingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class XiangQingService implements IXiangQingService {
    @Autowired
    private XiangQingMapper xiangQingMapper;

    @Override
    public boolean addXiangQing(XiangQing xiangQing){
        return xiangQingMapper.insert(xiangQing) > 0;
    }

    @Override
    public boolean deleteXiangQing(Integer xqid){
        return xiangQingMapper.deleteById(xqid) > 0;
    }

    @Override
    public boolean updateXiangQing(XiangQing xiangQing){
        return xiangQingMapper.updateById(xiangQing) > 0;
    }

    @Override
    public List<XiangQing> queryXiangQing(){
        return xiangQingMapper.selectList(null);
    }

    @Override
    public XiangQing queryXiangQingById(Integer xqid){
        return xiangQingMapper.selectById(xqid);
    }

    @Override
    public List<XiangQing> queryXiangQingByDdid(Integer ddid){
        return xiangQingMapper.selectList(new QueryWrapper<XiangQing>().eq("ddid",ddid));
    }

    @Override
    public List<XiangQing> queryXiangQingByddid(Integer ddid) {
        return xiangQingMapper.selectList(new LambdaQueryWrapper<XiangQing>()
                .eq(XiangQing::getDdid,ddid));
    }
}
